package com.day9;

public class Student implements Comparable<Student> {
    private String name;
    private int math;
    private int english;

    public Student() {
    }

    public Student(String name, int math, int english) {
        this.name = name;
        this.math = math;
        this.english = english;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getMath() {
        return math;
    }

    public void setMath(int math) {
        this.math = math;
    }

    public int getEnglish() {
        return english;
    }

    public void setEnglish(int english) {
        this.english = english;
    }

    @Override
    public String toString() {
        return "Student{" +
                "name='" + name + '\'' +
                ", math=" + math +
                ", english=" + english +
                '}';
    }

    public int getsum() {
        return math + english;
    }


    @Override
    public int compareTo(Student o) {
        int a = this.getsum() - o.getsum();
        int b = a == 0 ? this.getMath() - o.getMath() : a;
        int c = b == 0 ? this.getEnglish() - o.getEnglish() : b;
        return c;
    }
}
